package pdd;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-03-20 19:02
 */
public class PDD_0320_1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        int[] a=new int[n];
        int[] b=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=cin.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i]=cin.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int res=0;
        for (int i = 0; i < n; i++) {
            res+=Math.pow((a[i]-b[i]),2);
        }
        System.out.println(res);
    }
}
